<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>TagM: RTOS::pool&lt; T &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">TagM
   &#160;<span id="projectnumber">1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="class_r_t_o_s.html">RTOS</a></li><li class="navelem"><a class="el" href="class_r_t_o_s_1_1pool.html">pool</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">RTOS::pool&lt; T &gt; Class Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>place to store and rectrieve data, no built-in synchronisation  
 <a href="class_r_t_o_s_1_1pool.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="p_r_t_o_s_8h_source.html">pRTOS.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for RTOS::pool&lt; T &gt;:</div>
<div class="dyncontent">
 <div class="center">
  <img src="class_r_t_o_s_1_1pool.png" usemap="#RTOS::pool&lt; T &gt;_map" alt=""/>
  <map id="RTOS::pool&lt; T &gt;_map" name="RTOS::pool&lt; T &gt;_map">
<area href="class_r_t_o_s_1_1pool__base.html" title="RTOS private implementation class." alt="RTOS::pool_base" shape="rect" coords="0,0,109,24"/>
</map>
 </div></div>

<p><a href="class_r_t_o_s_1_1pool-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a34dfd08a46f1fd274f1692469eebaf36"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1pool.html#a34dfd08a46f1fd274f1692469eebaf36">pool</a> (const char *name=&quot;&quot;)</td></tr>
<tr class="memdesc:a34dfd08a46f1fd274f1692469eebaf36"><td class="mdescLeft">&#160;</td><td class="mdescRight">construct a pool, specify its name (for debgging only)  <a href="#a34dfd08a46f1fd274f1692469eebaf36"></a><br/></td></tr>
<tr class="memitem:a2bd2a2bfb99d74c8b123de344698ff53"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1pool.html#a2bd2a2bfb99d74c8b123de344698ff53">write</a> (T item)</td></tr>
<tr class="memdesc:a2bd2a2bfb99d74c8b123de344698ff53"><td class="mdescLeft">&#160;</td><td class="mdescRight">atomic write operation on a pool  <a href="#a2bd2a2bfb99d74c8b123de344698ff53"></a><br/></td></tr>
<tr class="memitem:a0ef6382b71ae141cf38f477c8bfea325"><td class="memItemLeft" align="right" valign="top">T&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_r_t_o_s_1_1pool.html#a0ef6382b71ae141cf38f477c8bfea325">read</a> (void)</td></tr>
<tr class="memdesc:a0ef6382b71ae141cf38f477c8bfea325"><td class="mdescLeft">&#160;</td><td class="mdescRight">atomic read operation on a pool  <a href="#a0ef6382b71ae141cf38f477c8bfea325"></a><br/></td></tr>
<tr class="inherit_header pub_methods_class_r_t_o_s_1_1pool__base"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_class_r_t_o_s_1_1pool__base')"><img src="closed.png" alt="-"/>&nbsp;Public Member Functions inherited from <a class="el" href="class_r_t_o_s_1_1pool__base.html">RTOS::pool_base</a></td></tr>
<tr class="memitem:a7ce39242e76cd0c2f1601155cb43f309 inherit pub_methods_class_r_t_o_s_1_1pool__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7ce39242e76cd0c2f1601155cb43f309"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>pool_base</b> (const char *name)</td></tr>
<tr class="memitem:a15b26e0b643798c8cc478398c054fd7e inherit pub_methods_class_r_t_o_s_1_1pool__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a15b26e0b643798c8cc478398c054fd7e"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>print</b> (std::ostream &amp;s, bool header=true) const </td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="inherited"></a>
Additional Inherited Members</h2></td></tr>
<tr class="inherit_header pub_attribs_class_r_t_o_s_1_1pool__base"><td colspan="2" onclick="javascript:toggleInherit('pub_attribs_class_r_t_o_s_1_1pool__base')"><img src="closed.png" alt="-"/>&nbsp;Public Attributes inherited from <a class="el" href="class_r_t_o_s_1_1pool__base.html">RTOS::pool_base</a></td></tr>
<tr class="memitem:a37744d640ecc23f39e6693f4e00e761c inherit pub_attribs_class_r_t_o_s_1_1pool__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a37744d640ecc23f39e6693f4e00e761c"></a>
unsigned int&#160;</td><td class="memItemRight" valign="bottom"><b>reads</b></td></tr>
<tr class="memitem:ae4c15f975a7aab7889ae54f266f91c56 inherit pub_attribs_class_r_t_o_s_1_1pool__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ae4c15f975a7aab7889ae54f266f91c56"></a>
unsigned int&#160;</td><td class="memItemRight" valign="bottom"><b>writes</b></td></tr>
<tr class="memitem:a8c13f0743810951752bf8791d06f03cd inherit pub_attribs_class_r_t_o_s_1_1pool__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8c13f0743810951752bf8791d06f03cd"></a>
<a class="el" href="class_r_t_o_s_1_1pool__base.html">pool_base</a> *&#160;</td><td class="memItemRight" valign="bottom"><b>next_pool</b></td></tr>
<tr class="memitem:a7aff133ec894002b944e7ec415dd658f inherit pub_attribs_class_r_t_o_s_1_1pool__base"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a7aff133ec894002b944e7ec415dd658f"></a>
const char *&#160;</td><td class="memItemRight" valign="bottom"><b>pool_name</b></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><h3>template&lt;class T&gt;<br/>
class RTOS::pool&lt; T &gt;</h3>

<p>place to store and rectrieve data, no built-in synchronisation </p>
<pre class="fragment">  A (communication) pool is a template class that stores a single value.
  It supports the read and write operations, which are guaranteed to be 
  atomic. (On a non-preemptive RTOS every assignment is atomic, 
  but the pool template is still usefull to make it explicit that
  data is transferred between tasks.) 
  A pool is just a variable. 

  The example below demonstrates the use of a pool to 
  maintain a seconds-since-startup counter. 
  Note that the call RTOS::runtime() returns the time elapsed since 
  startup, so there is no need to maintain a 
  seconds-since-startup this way yourself.

  @code 
</pre><p>pool&lt; unsigned int &gt; seconds;</p>
<p>void show_time( void ){ unsigned int n = seconds.read(); std::cout &lt;&lt; ( seconds / 60 ) % 60 &lt;&lt; ":" &lt;&lt; seconds % 60; }</p>
<p>class seconds_counter_class : public periodic_task { seconds_counter( void ){ periodic_task::periodic_task( "sec-counter", 10, 1000 MS ); seconds.write( 0 ); } void main( void ){ for(;;){ (void)wait(); // only one thing to wait for seconds.write( seconds.read() + 1 ); } } }</p>
<p>seconds_counter_class seconds_counter;</p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a34dfd08a46f1fd274f1692469eebaf36"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="class_r_t_o_s_1_1pool.html">RTOS::pool</a>&lt; T &gt;::<a class="el" href="class_r_t_o_s_1_1pool.html">pool</a> </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>name</em> = <code>&quot;&quot;</code></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>construct a pool, specify its name (for debgging only) </p>
<p>Use it to make (global) variables use for communication between tasks explicit.</p>
<p>The template argument T must be a class that has a non-arguments constructor and supports assignment. </p>

</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a0ef6382b71ae141cf38f477c8bfea325"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">T <a class="el" href="class_r_t_o_s_1_1pool.html">RTOS::pool</a>&lt; T &gt;::read </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>atomic read operation on a pool </p>
<p>A read opeartion returns the most recently written data.In the context of co-operative multitasking a read of write operation on anything is always atomic, unless the implementation of that operating somehow invokes the <a class="el" href="class_r_t_o_s.html" title="static class, namespace-like container for RTOS declarations">RTOS</a>. But for clearness it is a good idea to implement such task-global data as pools.  </p>

</div>
</div>
<a class="anchor" id="a2bd2a2bfb99d74c8b123de344698ff53"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;class T&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="class_r_t_o_s_1_1pool.html">RTOS::pool</a>&lt; T &gt;::write </td>
          <td>(</td>
          <td class="paramtype">T&#160;</td>
          <td class="paramname"><em>item</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>atomic write operation on a pool </p>
<p>A read opeartion returns the most recently written data.</p>
<p>In the context of co-operative multitasking a read of write operation on anything is always atomic, unless the implementation of that operating somehow invokes the <a class="el" href="class_r_t_o_s.html" title="static class, namespace-like container for RTOS declarations">RTOS</a>. But for clearness it is a good idea to implement such task-global data as pools. </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="p_r_t_o_s_8h_source.html">pRTOS.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Jun 27 2012 11:07:15 for TagM by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.1.1
</small></address>
</body>
</html>
